From: Keir Fraser Date: Thu, 8 Apr 2010 14:30:52 +0000 (+0100) Subject: xen: allow guests to set caching attributes for MMIOs X-Git-Tag: archive/raspbian/4.8.0-1+rpi1~1^2~12423 X-Git-Url: https://dgit.raspbian.org/%22http://www.example.com/cgi/success//%22http:/www.example.com/cgi/success/?a=commitdiff_plain;h=750b06dbd9be59968e8d13d81f1a2462fa93b3aa;p=xen.git xen: allow guests to set caching attributes for MMIOs This patch allows guests that have directly mapped MMIO regions to set the caching attributes for them, and only for them. Currently we have just an on/off check for a directly assigned device instead of looking for directly mapped MMIO regions. Signed-off-by: Stefano Stabellini --- diff --git a/xen/arch/x86/hvm/hvm.c b/xen/arch/x86/hvm/hvm.c index 7e50d5105a..7e261f24e1 100644 --- a/xen/arch/x86/hvm/hvm.c +++ b/xen/arch/x86/hvm/hvm.c @@ -1126,7 +1126,7 @@ int hvm_set_cr0(unsigned long value) } } - if ( has_arch_pdevs(v->domain) ) + if ( has_arch_mmios(v->domain) ) { if ( (value & X86_CR0_CD) && !(value & X86_CR0_NW) ) { diff --git a/xen/arch/x86/hvm/svm/svm.c b/xen/arch/x86/hvm/svm/svm.c index cbd5d79be5..d753a434ae 100644 --- a/xen/arch/x86/hvm/svm/svm.c +++ b/xen/arch/x86/hvm/svm/svm.c @@ -1228,7 +1228,7 @@ static void wbinvd_ipi(void *info) static void svm_wbinvd_intercept(void) { - if ( has_arch_pdevs(current->domain) ) + if ( has_arch_mmios(current->domain) ) on_each_cpu(wbinvd_ipi, NULL, 1); } diff --git a/xen/arch/x86/hvm/vmx/vmx.c b/xen/arch/x86/hvm/vmx/vmx.c index 928c86c8b5..cc4d3b1e8d 100644 --- a/xen/arch/x86/hvm/vmx/vmx.c +++ b/xen/arch/x86/hvm/vmx/vmx.c @@ -2109,7 +2109,7 @@ static void wbinvd_ipi(void *info) static void vmx_wbinvd_intercept(void) { - if ( !has_arch_pdevs(current->domain) ) + if ( !has_arch_mmios(current->domain) ) return; if ( cpu_has_wbinvd_exiting ) diff --git a/xen/arch/x86/mm/shadow/multi.c b/xen/arch/x86/mm/shadow/multi.c index 9a449b97e8..38be3863ee 100644 --- a/xen/arch/x86/mm/shadow/multi.c +++ b/xen/arch/x86/mm/shadow/multi.c @@ -28,6 +28,7 @@ #include #include #include +#include #include #include #include @@ -546,7 +547,8 @@ _sh_propagate(struct vcpu *v, * For HVM domains with direct access to MMIO areas, set the correct * caching attributes in the shadows to match what was asked for. */ - if ( (level == 1) && is_hvm_domain(d) && has_arch_pdevs(d) && + if ( (level == 1) && is_hvm_domain(d) && + iomem_access_permitted(d, mfn_x(target_mfn), mfn_x(target_mfn) + 1) && !is_xen_heap_mfn(mfn_x(target_mfn)) ) { unsigned int type; diff --git a/xen/include/asm-ia64/domain.h b/xen/include/asm-ia64/domain.h index d181b5f826..14064ce247 100644 --- a/xen/include/asm-ia64/domain.h +++ b/xen/include/asm-ia64/domain.h @@ -45,6 +45,7 @@ extern void panic_domain(struct pt_regs *, const char *, ...) __attribute__ ((noreturn, format (printf, 2, 3))); #define has_arch_pdevs(d) (!list_empty(&(d)->arch.pdev_list)) +#define has_arch_mmios(d) (!rangeset_is_empty((d)->iomem_caps)) struct mm_struct { volatile pgd_t * pgd; diff --git a/xen/include/asm-x86/domain.h b/xen/include/asm-x86/domain.h index de238a0492..35661b85b2 100644 --- a/xen/include/asm-x86/domain.h +++ b/xen/include/asm-x86/domain.h @@ -329,6 +329,7 @@ struct arch_domain } __cacheline_aligned; #define has_arch_pdevs(d) (!list_empty(&(d)->arch.pdev_list)) +#define has_arch_mmios(d) (!rangeset_is_empty((d)->iomem_caps)) #ifdef CONFIG_X86_64 #define perdomain_pt_pgidx(v) \